package com.itheima.d2_genericity_method;

import java.util.Arrays;

/**
 * 泛型方法
 */
public class test {
    public static void main(String[] args) {
        String[] names = {"汪汪","喵喵","呱呱"};
        Integer[] ages = {1,4,5};
        printArray(names);
        printArray(ages);
        String[] names2 = getArr(names);
        System.out.println(Arrays.toString(names2));

    }

    public static <E> void printArray(E[] arr){//注意：泛型方法的申明方法，前面要有<E>

            System.out.println(Arrays.toString(arr));

    }

    public static <E>  E[] getArr(E[] arr){//返回类型为泛型的方法
        return arr;
    }
}
